<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=<device-width>, initial-scale=1.0">
    <title>路由</title>
</head>
<body>
    <div id="btn">跳转</div>
    <script>
        // BrowserRouter 和 hashRouter
        // 哈希路由 和 history
        // hash # 开始 具有兼容性好 缺点不如history 和后端路由一样
        // HashChange pushState(html5 history对象上)  当前页面不会跳转 依赖的规则不一样
        const btn = document.getElementById('btn');
        btn.addEventListener('click',function() {
            window.location.href = '#/user' // BOM url 改变不跳转
        })
        window.onhashchange = (event) => {
           const newUrl = event.newURL;
           const oldUrl = event.oldURL;
           console.log(newUrl,oldUrl,location.hash)
        }
    </script>
</body>
</html>